package com.malty.mall.domain.entity.pms;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.malty.mall.domain.dto.req.pms.PmsBrandParam;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @author malty
 */
@Data
@NoArgsConstructor
@TableName("pms_brand")
public class PmsBrand {
    private Long id;
    private String name;
    private String firstLetter;
    private Integer sort;
    private Integer factoryStatus;
    private Integer showStatus;
    private Integer productCount;
    private Integer productCommentCount;
    private String bannerPic;
    private String logo;
    private String description;
    private Date createTime;
    private Date updateTime;

    public PmsBrand(PmsBrandParam brandParam) {
        BeanUtils.copyProperties(brandParam, this);
        if (StrUtil.isEmpty(brandParam.getFirstLetter())) {
            this.setFirstLetter(brandParam.getName().substring(0, 1));
        }
    }
}
